import axios from 'axios'



const instance = axios.create({
    //网络公共配置
    timeout: 5000
})

instance.interceptors.request.use(
    config => {
        // 在发送请求之前做些什么
        // console.log(config);
        console.log('请求头', config.headers);

    
        return config;
    },
    error => {
        // 对请求错误做些什么
        return Promise.reject(error);
    }
);

instance.interceptors.response.use(
    response => {

        return response;
    },
    error => {
        // 处理错误
        return Promise.reject(error.response ? error.response.data : error);
    }
);

const getData = async () => {
    try {
        const response = await instance.get('http://210.12.11.251:34010/peis/ins/authserver/api/account/password-login?__tenant=3a11fd58-c553-629e-f953-fc4d93144698');
        console.log('请求成功', response.data);
    } catch (error) {
        console.error('请求失败:', error);
    }
};

export default instance;